package com.yt.sys.api.cms;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.yt.common.constant.Result;
import com.yt.common.enums.CodeEnum;
import com.yt.common.utils.StrUtils;
import com.yt.sys.models.vo.ProfessionInfoVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List;
import com.yt.sys.models.service.IProfessionInfoService;
import com.yt.sys.models.bo.ProfessionInfoSaveBO;
import com.yt.sys.models.bo.ProfessionInfoBO;
import com.yt.sys.models.dto.ProfessionInfoDTO;

/**
 * 专业详情控制器
 *
 * @author thekai
 * @Date 2025-10-29 09:53:16
 */

@RestController
@RequestMapping("/cms/professionInfo")
@Slf4j
@Api(value = "ProfessionInfoController",tags = "专业详情接口")
public class ProfessionInfoController {

    @DubboReference
    private IProfessionInfoService professionInfoService;
    @ApiOperation(value = "添加专业详情",notes = "添加专业详情")
    @PostMapping(value = "/addprofession")
    public Result addprofession(@RequestBody ProfessionInfoSaveBO saveBO) {
        boolean flag = professionInfoService.add(saveBO);
        if (flag){
            return new Result<>();
        } else {
            return new Result<>(CodeEnum.FAIL_100007);
        }
    }
    @ApiOperation(value = "删除专业详情",notes = "删除专业详情")
    @ApiImplicitParam(name = "id",value = "专业详情id",required = true,paramType = "query",dataType = "Long")
    @PostMapping("/deleteprofession")
    public Result deleteprofession(@RequestParam("id") Long id){
        boolean flag = professionInfoService.deleteById(id);
        if (flag){
            return new Result<>();
        } else {
            return new Result<>(CodeEnum.FAIL_100009);
        }
    }

    @ApiOperation(value = "修改专业详情",notes = "修改专业详情")
    @PostMapping("/updateprofession")
    public Result updateprofession(@RequestBody ProfessionInfoSaveBO saveBO){
        ProfessionInfoDTO dto = new ProfessionInfoDTO();
        BeanUtils.copyProperties(saveBO, dto);
        dto.setId(saveBO.getId());
        boolean flag = professionInfoService.updateById(dto);
        if (flag){
            return new Result<>();
        } else {
            return new Result<>(CodeEnum.FAIL_100008);
        }
    }

    @PostMapping("/queryprofession")
    @ApiOperation(value = "查询专业详情信息", notes = "查询专业详情信息")
    public Result<List<ProfessionInfoVO>> queryprofession() {
        List<ProfessionInfoVO> professionInfoVOS = professionInfoService.query();
        return new Result<>(professionInfoVOS);
    }


}
